<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016-03-30
 * Time: 10:25
 */


/*****************************************
BEGIN
#Routine body goes here...
SELECT * from tb_admin;
SELECT * from tb_user;

END
 */

/*
$rows = array();
$db = new mysqli('127.0.0.1', 'root', 'pengbodb', 'db_online');
if (mysqli_connect_errno()) {
    $this->message('Can not connect to MySQL server');
}
$db->query("SET NAMES UTF8");
if ($db->real_query("call result()")) {
    do {
        if ($result = $db->store_result()) {
            $ft = array();
            $ft = $result->num_rows;
            var_dump($ft);
            while ($row = $result->fetch_assoc()) {
                //array_push($rows, $row);
                var_dump($row);
            }
            $result->close();
        }
        $db->next_result();
    } while ($db->more_results());
}
$db->close();*/









try {
    $dbh = new PDO('mysql:host=localhost;dbname=db_library', 'root', 'pengbodb');
    $stmt = $dbh->query("call pro_out(1,@pv);select @pv;");
    $res = array();
    $i = 1;
    do {
        $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
        $res[$i] = $rows;
        $i ++;
    } while ($stmt->nextRowset());
    $dbh = null;
    var_dump($res);
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "
";
    die();
}



//����ʹ��
/* $StartDate="2016-05-31";
       $EndDate="2016-06-02";
       $AStartDate="2016-05-31";
       $AEndDate="2016-06-02";
       $dest="A0B92C7B-8AE6-446B-A317-0FC767AF9070";
       $service=1;
       $Model = new Model(); // ʵ����һ��model���� û�ж�Ӧ�κ����ݱ�

       $res = $Model->query("exec  dbo.SaleOrderStatistics '".$StartDate."',"."'".$EndDate."',"."'".$AStartDate."',"."'".$AEndDate."',"."'".$dest."',".$service.';');

        var_dump($Model->getLastSql());*/

//sqlsrv ����ʹ��
/*$host="113.207.96.135,20565";
$connectInfo  =  array('Database'=>'CCTCQCRM','UID'=>'sa','PWD'=>'slowlook@sa2014','CharacterSet' => C('DEFAULT_CHARSET'), 'ReturnDatesAsStrings'=> true);
$conn=sqlsrv_connect($host,$connectInfo) or die('����ʧ��');
$StartDate="2016-05-31";
$EndDate="2016-06-02";
$AStartDate="2016-05-31";
$AEndDate="2016-06-02";
$dest="A0B92C7B-8AE6-446B-A317-0FC767AF9070";
$service=1;
$params = array(
    array($StartDate, SQLSRV_PARAM_IN),
    array($EndDate, SQLSRV_PARAM_IN),
    array($AStartDate, SQLSRV_PARAM_IN),
    array($AEndDate, SQLSRV_PARAM_IN),
    array($dest, SQLSRV_PARAM_IN),
    array($service, SQLSRV_PARAM_IN)
);


$sql_callSP = "{call dbo.SaleOrderStatistics(?,?,?,?,?,?)}";
$data = sqlsrv_query($conn,$sql_callSP,$params);
$ary=sqlsrv_fetch_array($data,SQLSRV_FETCH_ASSOC);
var_dump($ary);exit;
*/


